package cn.hrlly.tao2shou.presenter;

import android.content.Context;

import cn.hrlly.tao2shou.biz.MyRequireListBiz;
import cn.hrlly.tao2shou.biz.MyRequireListBizImpl;
import cn.hrlly.tao2shou.domain.RequireList;
import cn.hrlly.tao2shou.listener.OnMyRequireListListener;
import cn.hrlly.tao2shou.view.view_interface.MyRequireListView;

/**
 * User: gengliang
 * Date: 2016-01-30
 * Time: 09:56
 */

public class MyRequireListPresenterImpl implements MyRequireListPresenter,OnMyRequireListListener {

    private MyRequireListBiz myRequireListBiz;
    private MyRequireListView myRequireListView;

    public MyRequireListPresenterImpl(MyRequireListView myRequireListView,Context context){
        this.myRequireListBiz=new MyRequireListBizImpl(this,context);
        this.myRequireListView=myRequireListView;
    }

    @Override
    public void showMyRequireList() {
        myRequireListBiz.getNetMyRequireList();
    }

    @Override
    public void showCacheMyRequireList() {
        RequireList requireList=myRequireListBiz.getCacheMyRequireList();
        if(requireList!=null)
            myRequireListView.showListView(requireList);
    }

    @Override
    public void showMyRequireListSucc(RequireList requireList) {
        myRequireListView.showListView(requireList);

        //将数据缓存
        myRequireListBiz.saveCacheMyRequireList(requireList);
    }

    @Override
    public void showMyRequireListFail(int errorMessage) {
        myRequireListView.showMessage(errorMessage);
    }

    @Override
    public void showMyRequireListFail(String errorMessage) {
        myRequireListView.showMessage(errorMessage);
    }
}
